<?php
namespace app\appoint\model;
use app\BaseModel;
use think\facade\Db;



class AdminCate extends BaseModel
{
    //定义表名
    protected $name = 'lb_appoint_classify';
    /**
     * @param $query
     * 查询范围
     */
    public function scopeStatus($query, $status){
        $query->where('status', '>', $status);
    }
    /**
     * @param $dis
     * @return array
     * @throws \think\exception\DbException
     * 预约分类列表
     */
    public function cateList($dis,$page){
        $data = $this->where($dis)->status(-1)->order('top desc')->paginate($page)->toArray();
        return $data;
    }

    /**
     * @param $dis
     * @return array
     * @throws \think\exception\DbException
     * 预约分类
     */
    public function cateSelect($dis){
        $data = $this->where($dis)->status(-1)->order('top desc')->select()->toArray();
        return $data;
    }
    /**
     * @param $data
     * @return int|string
     * 添加预约分类
     */
    public function cateAdd($data){
        $data['create_time'] = time();
        $data['update_time'] = time();
        $data['status']      = 1;
        $res = $this->insert($data);
        return $res;
    }
    /**
     * @param $dis
     * @param $data
     * @return AdminCate
     * 编辑预约分类
     */
    public function cateUpdate($dis,$data){
        $data['update_time'] = time();
        $res = $this->where($dis)->update($data);
        return $res;

    }
    /**
     * @param $dis
     * 预约分类详情
     */
    public function cateInfo($dis){
        $data = $this->where($dis)->status(-1)->find();
        return !empty($data)?$data->toArray():$data;
    }



}